<template>
  <div class="login_page">
    <form class="login_form">
      <div class="segment">
        <h1>登录</h1>
      </div>
      <label>
        <input v-model="loginForm.phone" type="text" placeholder="请输入账号" />
      </label>
      <label>
        <input
          v-model="loginForm.passWord"
          type="password"
          placeholder="请输入密码"
        />
      </label>
      <button class="red" @click="submitForm" type="button">
        <i class="icon ion-md-lock"></i>
        Log in
      </button>
    </form>
  </div>
</template>
<script setup lang="ts">
import { loginApi } from '@/api/login'
import { ref } from 'vue'
import { useRouter } from 'vue-router'
const router = useRouter()
let loginForm = ref({
  phone: '', // 管理员账号
  passWord: '', // 管理员密码
})
// 管理登录的方法
const submitForm = async () => {
  let res: any = await loginApi(loginForm.value)

  if (res.status == 0) {
    localStorage.setItem('session', res.data.session)
    router.push({
      path: '/home',
    })
  }
}
</script>
<style lang="scss" scoped>
$ruler: 16px;
$color-red: #ae1100;
$color-bg: #ebecf0;
$color-shadow: #babecc;
$color-white: #fff;
.login_page {
  position: fixed;
  background-image: url(http://146.56.207.205:3111/images/voicu-apostol-93F3aiv_ioM-unsplash.jpg);
  background-size: 100% 100%;
  background-repeat: no-repeat;

  width: 100%;
  height: 100%;
}
.login_form {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -70%);
}
body,
p,
input,
select,
textarea,
button {
  font-family: 'Montserrat', sans-serif;
  letter-spacing: -0.2px;
  font-size: $ruler;
}

div,
p {
  color: $color-shadow;
  text-shadow: 1px 1px 1px $color-white;
}

form {
  padding: $ruler;
  width: $ruler * 20;
  margin: 0 auto;
}

.segment {
  padding: $ruler * 2 0;
  text-align: center;
}

button,
input {
  border: 0;
  outline: 0;
  font-size: $ruler;
  border-radius: $ruler * 20;
  padding: $ruler;
  background-color: $color-bg;
  text-shadow: 1px 1px 0 $color-white;
}

label {
  display: block;
  margin-bottom: $ruler * 1.5;
  width: 100%;
}

input {
  margin-right: 8px;
  box-shadow: inset 2px 2px 5px $color-shadow, inset -5px -5px 10px $color-white;
  width: 100%;
  box-sizing: border-box;
  transition: all 0.2s ease-in-out;
  appearance: none;
  -webkit-appearance: none;

  &:focus {
    box-shadow: inset 1px 1px 2px $color-shadow,
      inset -1px -1px 2px $color-white;
  }
}

button {
  color: #61677c;
  font-weight: bold;
  box-shadow: -5px -5px 20px $color-white, 5px 5px 20px $color-shadow;
  transition: all 0.2s ease-in-out;
  cursor: pointer;
  font-weight: 600;

  &:hover {
    box-shadow: -2px -2px 5px $color-white, 2px 2px 5px $color-shadow;
  }
  &:active {
    box-shadow: inset 1px 1px 2px $color-shadow,
      inset -1px -1px 2px $color-white;
  }

  .icon {
    margin-right: 8px;
  }

  &.red {
    display: block;
    width: 100%;
    color: $color-red;
  }
}
</style>
